package top.xylweb.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.xylweb.user.entity.User;
import top.xylweb.user.service.UserService;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("index")
    public String Test(){
        return "login";
    }

    @RequestMapping("home")
    public String home(){
        return "home";
    }

    /**
     * @Author X [**.**.**]
     * @Date 2017/12/18 16:57
     * Description  获取用户信息
     **/
    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){
        User user = (User) session.getAttribute("userinfo");
        return user;
    }


    /**
     * @Author X [**.**.**]
     * @Date 2017/12/18 18:22
     * Description  退出系统
     **/
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "login";
    }

}
